﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using Ue.Utility;

namespace Ue.Core.FileSystems
{
    public class FolderRoot : IFolderRoot
    {
        public FolderRoot() : this(string.Empty) { }

        public FolderRoot(string path)
        {
            if (path.IndexOf(Path.VolumeSeparatorChar) >= 0)
            {
                RootPath = string.Empty;
                this.RootPhysicalPath = path;
            }
            else
            {
                path = PathUtility.PhysicsPathSeparatorCharConvertToVirtualPathSeparatorChar(path);
                path = path.TrimEnd('/');

                this.RootPath = Path.Combine("/", path);
                this.RootPhysicalPath = Environment.CurrentDirectory + PathUtility.VirtualPathSeparatorCharConvertToPhysicsPathSeparatorChar(this.RootPath.TrimEnd('/'));
            }
        }

        #region IFolderRoot 成员

        public string RootPath { get; private set; }

        public string RootPhysicalPath { get; private set; }

        #endregion
    }
}
